<?php
  /**
   * @author EVANDRO DE OLIVEIRA.
   * @category VIEW
   * @package VIEWS/SCRIPTS/MATRICULAS.
   * @since 31/03/2012.
   * @last_update 31/03/2012.
   * @copyright 2012.
   * @version 1.0.
   *
   */
?>
<script type="text/javascript">
  $(function(){
    $('#idCurso').change(function(){
      strUrl = '<?=$this->baseUrl?>/matriculas/load-modulos-ajax/idCurso/' + $(this).val();
      $('#listaModulos').load(strUrl);                    
    });
  });
</script>
<table border="0" align="center" cellpadding="0" cellspacing="0" class="content-view" id="teste">
  <tr>
    <td id="messenger" colspan="2"><?php echo $this->flashMessage();?></td>
  </tr>
  <tr>
    <td align="left" class="comp-title" style="width: 200px; text-transform: uppercase;">Curso e Turma</td>  
    <td>&nbsp;</td>
  </tr>
  
  <tr>
    <td align="center" colspan="2">
      <table border="0" align="center" cellpadding="0" cellspacing="0" width="100%" class="content-form">
        <tr>
          <td class="space-bottom"></td>
        </tr>
        <tr>
          <td>
            <form name="form_add" method="post" action="" id="form_add">
              <table border="0" align="left" cellpadding="0" cellspacing="0" width="100%">
                <?php          
                  //Zend_Debug::dump($this->request);
                  foreach($this->arrColunas as $strKey => $arrValues){
                  	//Zend_Debug::dump($arrValues);
                    switch($arrValues['type']){
                      case 'text':
                        $strCampo = $this->input($arrValues['type'], $arrValues['name'], $arrValues['name'], isset($arrValues['default_value']) ? $arrValues['default_value'] : $this->request[$arrValues['name']], isset($arrValues['enabled']) ? $arrValues['enabled'] : true, '', $arrValues['maxlength'], '', "width: {$arrValues['width']}px;");
                      break;
                      
                      case 'textarea':
                        $strCampo = $this->textarea($arrValues['name'], $arrValues['name'], $this->request[$arrValues['name']], true, $arrValues['cols'], $arrValues['rows']);
                      break;
                      
                      case 'db_combo':
                        $strCampo = $this->dbComboBox($arrValues['name'], $arrValues['name'], $arrValues['model'], $arrValues['value'], $arrValues['label'], !empty($this->request[$arrValues['value']]) ? $this->request[$arrValues['value']] : '', !empty($this->request[$arrValues['label']]) ? $this->request[$arrValues['label']]: 'Selecione', true, $arrValues['label'], null, array('ds_situacao' => '1'));
                      break;

                      case 'combo':
                        $strCampo = $this->comboBox($arrValues['name'], $arrValues['name'], $arrValues['options'], !empty($arrValues['name']) ? $this->request[$arrValues['name']] : 'Selecione');
                      break;
                      
                      case 'date':
                      case 'datetime':  
                        $strCampo = $this->input('text', $arrValues['name'], $arrValues['name'] , $arrValues['default_value'], false, '', '', $arrValues['maxlength'], "width: {$arrValues['width']}px;");
                      break;
                      
                      case 'hidden':
                        $strCampo = $this->input($arrValues['type'], $arrValues['name'], $arrValues['name'], isset($arrValues['default_value']) ? $arrValues['default_value'] : $this->request[$arrValues['name']], isset($arrValues['enabled']) ? $arrValues['enabled'] : true, '', $arrValues['maxlength'], '', "width: {$arrValues['width']}px;");
                      break; 
                    }
                    if($arrValues['type'] != 'hidden'){?>
                      <tr>    
                        <td align="right" class="label">
                          <?php 
                            echo $arrValues['notnull'] ? '<span style="color: #FF0000; font-weight: bold"> * </span>' . $strKey : $strKey;
                          ?>:
                        </td>  
                        <td align="left" class="space-bottom">
                          <?php
                            if($arrValues['name'] == 'idModulo'){?>
                              <div id="listaModulos"><?php  echo $strCampo?></div>
                              <?php 
                            }
                            elseif($arrValues['name'] == 'idTurma'){?>
                              <div id="listaTurmas"><?php  echo $strCampo?></div>
                              <?php 
                            } 
                            else{
                            	echo $strCampo;
                            }
                          ?>
                        </td>
                        <td><span>&nbsp;</span></td>                     
                      </tr>     
                      <?php
                    }
                    else{
                      ?>
                        <tr>
                          <td align="right" class="label"></td>  
                          <td align="left" class="space-bottom"><?php echo $strCampo?></td>   
                          <td><span>&nbsp;</span></td>                     
                        </tr>               
                      <?php
                    }  	
                  }
                ?>
                <tr>  
                  <td align="left">
                    <?php 
                      echo $this->input('button', 'cancel', 'boton', '<< Voltar', true, '', '', '', '', "onclick=\"window.location='list'\"");
                    ?>
                  </td>
                  <td><span>&nbsp;</span></td>
                  <td align="right">
                    <?php 
                      echo $this->input('submit', 'save', 'boton', 'Avançar >>', true);
                    ?>
                  </td>
                </tr>
              </table>
            </form>
          </td>
        </tr>
      </table>
    </td>
  </tr>  
</table>